package com.wxzhou.wangzhuan.util;

import com.wxzhou.wangzhuan.constants.CacheNames;
import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.config.inject.ConfigProperty;

/**
 * Redis键构建工具（重构版）
 * 专注于手动构建Redis键，与@CacheResult分离
 *
 * @author 系统重构
 * @since 2.0
 */
@ApplicationScoped
public class RedisKeyUtil {

    @ConfigProperty(name = "redis.manual.prefix", defaultValue = "wangzhuan:")
    String keyPrefix;

    @ConfigProperty(name = "token.expire.seconds", defaultValue = "864000")
    long tokenExpireSeconds;

    // ==================== 手动Redis键构建方法 ====================

    /**
     * 构建用户token键
     */
    public String buildTokenKey(String token) {
        return keyPrefix + CacheNames.KEY_TOKEN + ":" + token;
    }

    public String buildButieKey(Long userid) {
        return keyPrefix + CacheNames.KEY_USER_BUTIE_PREFIX + ":" + userid;
    }

    /**
     * 获取当前配置的键前缀
     */
    public String getKeyPrefix() {
        return keyPrefix;
    }

    // ==================== 配置获取方法 ====================

    /**
     * 获取token过期时间
     */
    public long getTokenExpireSeconds() {
        return tokenExpireSeconds;
    }
}